/* https://leetcode.cn/problems/kth-missing-positive-number/submissions/563962599/ */
/* 1539. 第 k 个缺失的正整数 */
/* 难度：简单 时间10/9 */
/* 二分搜索 */

代码：
class Solution
{
public:
    int findKthPositive(vector<int> &arr, int k)
    {
        int l = 0, r = arr.size() - 1;
        while (l <= r)
        {
            int mid = l + (r - l) / 2;
            int miss_l = arr[mid] - mid - 1; // 计算左半区间的缺失个数
            if (miss_l < k)
            {
                l = mid + 1;
            }
            else
            {
                r = mid - 1;
            }
        }
        return l + k;
    }
};